<?php


namespace app\common\model;


use think\Exception;

class ZhunleCounselorProblemPrice extends Base
{
    protected $table = 'wechat_backup_07_18_14_43_00.zhunle_couselor_problem_price';

    /**
     * 获取公开悬赏价格
     * @return array
     * @throws Exception
     */
    public function getOpenedPrice()
    {
        //todo redis缓存
        try
        {
            $priceDataArray = $this->where(['status' => 1])->order('sort', 'asc')
                ->column('id,people,price', 'id');
        }
        catch (Exception $e)
        {
            throw new Exception('服务异常', 0);
        }

        return $priceDataArray;
    }

    /**
     * 获取咨询价格
     * @param $id
     * @return mixed
     * @throws Exception
     */
    public function getProblemOpenedPrice($id)
    {
        $openedPrices = $this->getOpenedPrice();

        return $openedPrices[$id] ?? [];
    }
}
